package com.teamwings.api.rabbitmq;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.teamwings.ctrls.entity.OatAppSupervision;
import com.teamwings.ctrls.entity.OatAppUrge;
import com.teamwings.ctrls.service.OatAppSupervisionService;
import com.teamwings.ctrls.service.OatAppUrgeService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.boot.starter.rabbitmq.constant.MqConstant;
import org.jeecg.boot.starter.rabbitmq.vo.FormFlowStateVo;
import org.jeecg.common.annotation.RabbitComponent;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;


@Slf4j
@RabbitComponent(value = "workFlow_mq")
public class WorkFlowMq  {

    @Autowired
    private OatAppSupervisionService supervisionService;
    @Autowired
    private OatAppUrgeService urgeService;


    @RabbitListener(queues = MqConstant.MQ_WORKFLOW_FORM_STATE )
    public void onMessage(FormFlowStateVo vo) {
        System.out.println(vo);
    }

//    // 接收流程被取消办理的流程实例信息
//    @RabbitListener(queues = MqConstant.MQ_WORKFLOW_FORM_CANCEL )
//    public void onMessageForWorkflowCancel(JSONObject jsonObject) {
//        InstanceVo instanceVo = JSON.toJavaObject(jsonObject, InstanceVo.class);
//        supervisionService.remove(new LambdaQueryWrapper<OatAppSupervision>()
//            .eq(OatAppSupervision::getFormId, instanceVo.getFFormInstId()));
//        urgeService.remove(new LambdaQueryWrapper<OatAppUrge>()
//            .eq(OatAppUrge::getFormId, instanceVo.getFFormInstId()));
//    }

}
